package com.job.dao.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.job.controller.req.CorporationInfoVO;
import com.job.dao.PositionDao;
import com.job.mapper.PositionInfoMapper;
import com.job.mapper.PositionMapper;
import com.job.pojo.Position;
import com.job.pojo.PositionInfo;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class PositionDaoImpl implements PositionDao {

    @Resource
    private PositionInfoMapper positionInfoMapper;

    @Resource
    private PositionMapper positionMapper;

    @Override
    public Page<Position> queryPositionByCorporationId(CorporationInfoVO corporationInfoVO) {
        Page<Position> page = new Page<>();
        page.setCurrent(corporationInfoVO.getCurrent());
        page.setSize(corporationInfoVO.getSize());
        LambdaQueryWrapper<Position> positionLambdaQueryWrapper = new LambdaQueryWrapper<>();
        positionLambdaQueryWrapper.eq(Position::getCorporationId,corporationInfoVO.getCorporationId());
        return positionMapper.selectPage(page,positionLambdaQueryWrapper);
    }

    @Override
    public PositionInfo queryPositionInfo(Integer positionId) {
        LambdaQueryWrapper<PositionInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PositionInfo::getPositionId,positionId);
        return  positionInfoMapper.selectOne(wrapper);
    }
}
